<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="https://git.oschina.net/cool_snail/neo-snail.git" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/static/lib/html5.js"></script>
<script type="text/javascript" src="/static/lib/respond.min.js"></script>
<script type="text/javascript" src="/static/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="/static/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/static/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="/static/css/style.css" rel="stylesheet" type="text/css" />
<link href="/static/lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/jquery-treetable/stylesheets/jquery.treetable.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/jquery-treetable/stylesheets/jquery.treetable.theme.default.css">
</head>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 资源管理 <a id="refresh"
			class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i
			class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="pd-20">
	<c:if test="${not empty msg}">
		<div class="message">${msg}</div>
	</c:if>

	<table id="table" class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th>名称</th>
				<th>类型</th>
				<th>URL路径</th>
				<th>权限字符串</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${resourceList}" var="resource">
				<tr data-tt-id='${resource.id}'
					<c:if test="${not resource.rootNode}">data-tt-parent-id='${resource.parentId}'</c:if>>
					<td>${resource.name}</td>
					<td>${resource.type.info}</td>
					<td>${resource.url}</td>
					<td>${resource.permission}</td>
					<td><shiro:hasPermission name="resource:create">
							<c:if test="${resource.type ne 'button'}">
								<a href="${pageContext.request.contextPath}/backend/resource/${resource.id}/appendChild">添加子节点</a>
							</c:if>
						</shiro:hasPermission> <shiro:hasPermission name="resource:update">
							<a
								href="${pageContext.request.contextPath}/backend/resource/${resource.id}/update">修改</a>
						</shiro:hasPermission> <c:if test="${not resource.rootNode}">

							<shiro:hasPermission name="resource:delete">
								<a class="deleteBtn" href="#" data-id="${resource.id}">删除</a>
							</shiro:hasPermission>
						</c:if></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	</div>
	<script
		src="${pageContext.request.contextPath}/static/js/jquery-1.11.0.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/jquery-treetable/javascripts/src/jquery.treetable.js"></script>
	<script>
    $(function() {
        $("#table").treetable({ expandable: true }).treetable("expandNode", 1);
        $(".deleteBtn").click(function() {
            if(confirm("确认删除吗?")) {
                location.href = "${pageContext.request.contextPath}/backend/resource/"+$(this).data("id")+"/delete";
            }
        });
    });
</script>
</body>
</html>